"""
generate commands by param
"""

import re


def generate_command(args: dict, step_name: str) -> str:
    """_summary_

    Args:
        args (dict): _description_
        step_name (str): _description_
    command =s:
        str: _description_
    """
    command = ""
    if step_name == "step2":
        command = f"""{args["commands"]} \
        {args["options"]} \
        -T {args["cores"]} \
        -1 {args["input_dir"]}/{args["file_names"][0]} \
        -2 {args["input_dir"]}/{args["file_names"][1]} \
        -o {args["output_dir"]} \
        -C {args["sample_name"]}_1.fq.gz \
        -D {args["sample_name"]}_2.fq.gz
        """

    elif step_name == "step3":
        command = f"""{args["commands"]} \
        {args["options"]} \
        -p {args["cores"]} \
        -x {args["hisat2_index_directory"]} \
        -1 {args["input_dir"]}/{args["sample_name"]}_1.fq.gz \
        -2 {args["input_dir"]}/{args["sample_name"]}_2.fq.gz | samtools \
        sort -@ {args["cores"]} -O bam -o {args["output_dir"]}/{args["sample_name"]}.bam \
        && samtools index {args["output_dir"]}/{args["sample_name"]}.bam \
	    && samtools flagstat {args["output_dir"]}/{args["sample_name"]}.bam > {args["output_dir"]}/{args["sample_name"]}.stat
        """
    elif step_name == "step4":
        command = f"""{args["commands"]} \
        {args["input_dir"]}/{args["sample_name"]}.bam \
        {args["options"]} \
        -p {args["cores"]} \
        -G {args["reference_annotation"]} \
        -A {args["output_dir"]}/{args["sample_name"]}_gene_exp.txt
        """

    new_command = re.sub(r"\s+", " ", command).strip()
    return new_command
